package com.zhangjm.pojo;

import com.zhangjm.pojo.enums.DecorateEnum;
import lombok.Data;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;

@Data
@Entity
@Table(name="s_house")
public class House implements Serializable {

    private static final long serialVersionUID = 1L;
    /** 标注用于声明一个实体类的属性映射为数据库的主键列。**/
    @Id
    /** 用于标注主键的生成策略，通过strategy 属性指定。**/
    /** JPA 自动选择一个最适合底层数据库的主键生成策略**/
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @Column
    private String name;

    @Column
    private Integer province;

    @Column
    private Integer city;

    @Column
    private Integer county;

    @Column
    private String community;

    @Column
    private Integer room;

    @Column
    private Integer hall;

    @Column
    private Integer toilet;

    @Column
    private String orientation;

    @Column
    private DecorateEnum decorate;

    @Column
    private BigDecimal rent;

    @Column
    private String pic;

    @Column
    private String introduction;

    @ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
    @JoinColumn(name = "province",referencedColumnName = "id",insertable = false,updatable = false)
    private Citys pname;

    @ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
    @JoinColumn(name = "city",referencedColumnName = "id",insertable = false,updatable = false)
    private Citys cname;

    @ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
    @JoinColumn(name = "county",referencedColumnName = "id",insertable = false,updatable = false)
    private Citys dname;
}
